home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_03 / kamradt / inline2.h < prev    next >
Text File  |  1994-02-07  |  1KB  |  36 lines

  1. Figure 4a. Splitting functions to facilitate inlining.
  2.  
  3. 5.1274 10000 Widget *WidgetHome::GetWidgetPointer() 
  4.              {
  5. 1.0333 10000   if(widgetPtr == NULL)
  6.                {
  7. 0.0012 10         widgetPtr = new Widget;
  8. 0.0013 10         if(widgetPtr == NULL || 
  9.                       widgetPtr->isError())
  10. 0.0000 0            return NULL;
  11.                }
  12. 1.0237 10000    return widgetPtr;
  13. 3.5429 10000 }
  14.  
  15.  
  16. Figure 4b.  Inlining only the part called most often.
  17.  
  18.              // the inline doesn't show up on the profile count:
  19.  
  20.              inline Widget *WidgetHome::GetWidgetPointer() 
  21.              {
  22.                return widgetPtr ? 
  23.                  widgetPtr : 
  24.                  PrivateGetWidgetPointer();
  25.              }
  26.  
  27. 0.0020 10    Widget *WidgetHome::PrivateGetWidgetPointer();
  28.              {
  29. 0.0059 10      widgetPtr = new Widget;
  30. 0.0035 10      if(widgetPtr == NULL || 
  31.                    widgetPtr->isError())
  32. 0.0000 0         return NULL;
  33. 0.0008 10      return widgetPtr;
  34. 0.0001 10    }
  35.  
  36.